<template>
	<view class="content">
		<web-view :webview-styles="webviewStyles" :src="link">
			<cover-view class="like" v-if="loaded">
				<cover-view class="shoucang bootchild list-icon" @click="isaddfn">
					<cover-view class="list-icon" v-if="!isadd">&#xe71f;</cover-view>
					<cover-view class="list-icon aboutadd" v-else>&#xe666;</cover-view>
				</cover-view>
			</cover-view>
		</web-view>
	</view>
</template>

<script>
	import {common} from '@/common/publish.js';
	export default {
		data() {
			return {
				webviewStyles:{
					
				},
				link:'',
				loaded:false,
				isadd:false,
				title:''
			};
		},
		onLoad(option){
			console.log(option)
			this.title = option.title;
			wx.showShareMenu()
			this.link = JSON.parse(decodeURIComponent(option.link));
			setTimeout(()=>{
				this.loaded = true;
			},500)
		},
		onShareAppMessage(res){
			let that = this;
			return{
				title:that.title,
				path:'/pages/turnLink/turnLink?type=index&link='+encodeURIComponent(JSON.stringify(link))+'&title='+title
			}
		},
		methods:{
			isaddfn(){
				if(this.isadd){
					//取消
					that.isadd = false;
					uni.request({
						url:common.csurl+'/api/collect/cancel.json',
						data:{
							unionId:that.userinfo.unionId,
							type:that.type,
							collectId:that.dataa.id
						},
						success(res) {
							if(res.data){
								that.isadd = false;
							}
						}
					})
					
				}else{
					//收藏
					that.isadd = true;
					uni.request({
						url:common.csurl+'/api/collect/save.json',
						data:{
							unionId:that.userinfo.unionId,
							type:that.type,
							collectId:that.dataa.id,
							title:that.dataa.title,
							picture:that.dataa.picture,
							web :1
						},
						success(res) {
							console.log(res.data)
							if(res.data){
								that.isadd = true;
							}
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.content{
		.like{
			position: fixed;
			bottom: 0;
			left: 0;
			height: 60upx;
			width: 100%;
			background-color: red;
			z-index: 9999999999999;
		}
	}
</style>